/**
 * @ author: 汪孟苹
 */
define([], function () {
    var tpl = {};

    tpl.init = function () {
        var html = '';
        html += list();
        return html;
    }
    tpl.init2 = function () {
        var html = '';
        html += basicInfoCard();
        return html;
    }
    tpl.init3 = function () {
        var html = '';
        html += categoryList();
        return html;
    }
    tpl.init4 = function () {
        var html = '';
        html += thead();
        return html;
    }
    tpl.init5 = function () {
        var html = '';
        html += tbody();
        html += group();

        html += text();
        html += texts();
        html += tick();
        html += tickText();
        html += radioInput();

        return html;
    }

    /**
     * 专科袋患者列表
     */
    var list = function () {
        return '<script id="tpl_specialtyBag_list" type="text/html">' +
            '	{{each rows as value i}}' +
            '	<div class="row babyList" patientId="{{value.patientId}}">' +
            '        <div class="col-xs-5 col-sm-5 col-md-5 babyList-name ellipsis-1">{{value.patientName}}</div>' +
            '        <div class="col-xs-7 col-sm-7 col-md-7 babyList-queue ellipsis-1">{{value.followQueueName}}</div>' +
            '   </div>' +
            '	{{/each}}' +
            '</script>';
    }

    /**
     * 专科袋患者详细信息info
     */
    var basicInfoCard = function () {
        return '<script id="tpl_specialtyBag_basicInfoCard" type="text/html">' +
            '		<div class="row basicInfo_1">' +
            '			<div class="col-xs-2 col-sm-2 col-md-2 basicInfo_1-left">' +
            '                <img class="babyIcon" src="page/followup/imgs/comm/{{genderPic}}.png">' +
            '            </div>' +
            '           <div class="col-xs-8 col-sm-8 col-md-8 basicInfo_1-right">' +
            '               <div class="row">' +
            '                   <div class="babyName">{{patientName}}</div>' +
            '               </div>' +
            '               <div class="row babyInfo">' +
            '                   <span>{{genderShow}}</span>' +
            '					{{if gestationShow}}' +
            '                   <span>{{pregnancyWeek}}</span>' +
            '					{{/if}}' +
            '                   <span >{{phoneNum}}</span>' +
            '               </div>' +
            '           </div>' +
            '		</div>' +
            '		<div class="row basicInfo_2">' +
            '			<div class="pull-left">{{followQueueName}} / {{schemeName}}</div>' +
            //'			<div class="pull-left">{{followQueueName}}</div>'+
            '    		<div class="pull-right">随访完成度：{{completeNum}} / {{totalNum}}</div>' +
            '		</div>' +
            '		<div class="row basicInfo_3">' +
            '			<div class="progress-wrap">' +
            '				{{each taskStatusArr as value i}}' +
            '					<div style="width:{{width}}"><i class="{{value}}"></i></div>' +
            '				{{/each}}' +
            '			</div>' +
            '		</div>' +
            '</script>';
    }

    /**
     * 专科袋患者categoryList列表
     */
    var categoryList = function () {
        return '<script id="tpl_specialtyBag_categoryList" type="text/html">' +
            '	{{each rows as value i}}' +
            '		<div class="row item" questionnaireId="{{value.questionnaireId}}">{{value.questionnaireName}}</div>' +
            '	{{/each}}' +
            '	{{if flag}}' +
            '		<div class="row collect" questionnaireId="{{rows[0].questionnaireId}}">生物样本收集记录</div>' +
            '	{{/if}}' +
            '</script>';
    }

    /**
     * 专科袋表格头部
     */
    var thead = function () {
        return '<script id="tpl_specialtyBag_thead" type="text/html">' +
            '	<tr>' +
            '		<th colspan="2">题目</th>' +
            '		{{each rows as value i}}' +
            '		<th taskId="{{value.taskId}}">{{value.taskName}}</th>' +
            '		{{/each}}' +
            '	</tr>' +
            '</script>';
    }

    /**
     * 专科袋表格tbody
     */
    var tbody = function () {
        return '<script id="tpl_specialtyBag_tbody" type="text/html">' +
            '	{{include "tpl_specialtyBag_group"}}' +
            '</script>';
    }
    var group = function () {
        return '<script id="tpl_specialtyBag_group" type="text/html">' +
            '	{{each children as value1 i}}' +
            '	{{each value1 as value i}}' +
            '		{{if value.type=="question_text" || value.type=="question_calc" || value.type=="question_staticText" || value.type=="question_date" || value.type=="question_textarea" || value.type=="question_select" || value.type=="question_sudoku" || value.type=="question_multiText" || value.type=="question_address" || value.type=="question_multiTextSelect" || value.type=="question_multiSelect" || value.type=="question_multiLabelText" || value.type=="question_textareaAssess"}}' +
            '			<tr>' +
            '				<td colspan="2">{{value.label}}</td>' +
            '				{{include "tpl_specialtyBag_text",value}}' +
            '			</tr>' +
            '		{{else if value.type=="question_growthComplex" || value.type=="question_growthSimple"}}' +
            '			{{each value.children as val i}}' +
            '			<tr>' +
            '				<td colspan="2">{{val.label}}</td>' +
            '				{{include "tpl_specialtyBag_text",val}}' +
            '			</tr>' +
            '			{{/each}}' +
            '		{{else if value.type=="question_checkbox" || value.type=="question_radio" || value.type=="question_checkboxRelation" || value.type=="question_radioRelation"}}' +
            '			{{each value.list as item k}}' +
            '			<tr>' +
            '				{{if item.index==0}}' +
            '				<td rowspan="{{value.num}}">{{value.label}}</td>' +
            '				{{/if}}' +
            '				<td>{{item.text}}</td>' +
            '				{{include "tpl_specialtyBag_tick",item}}' +
            '			</tr>' +
            '			{{/each}}' +
            '		{{else if value.type=="question_checkboxWithInput" || value.type=="question_radioWithInput"}}' +
            '			{{each value.list as item k}}' +
            '			<tr>' +
            '				{{if item.index==0}}' +
            '				<td rowspan="{{value.num}}">{{value.label}}</td>' +
            '				{{/if}}' +
            '				<td>{{item.text}}</td>' +
            '				{{include "tpl_specialtyBag_tickText",item}}' +
            '			</tr>' +
            '			{{/each}}' +
            '		{{else if value.type=="question_radioInput" || value.type=="question_checkboxInput"}}' +
            '			{{include "tpl_specialtyBag_radioInput",value}}' +
            '		{{else if value.type=="question_uploadPictures"}}' +
            '			<tr>' +
            '				<td colspan="2">{{value.label}}</td>' +
            '				{{include "tpl_specialtyBag_texts",value}}' +
            '			</tr>' +
            '		{{/if}}' +
            '	{{/each}}' +
            '	{{/each}}' +
            '</script>';
    }

    var radioInput = function () {
        return '<script id="tpl_specialtyBag_radioInput" type="text/html">' +

            '	{{each children[0].list as item k}}' +
            '		<tr>' +
            '			{{if item.index==0}}' +
            '			<td rowspan="{{children[0].num}}">{{children[0].label}}</td>' +
            '			{{/if}}' +
            '			<td>{{item.text}}</td>' +
            '			{{each item.val as val k1}}' +
            '				<td>' +
            '					{{if val=="true"}}' +
            '						{{if relevantText == item.text}}' +
            '							{{each children[1].value as val2 k2}}' +
            '								{{if k2 == k1}}' +
            '									{{if val2}}' +
            '										{{val2}}' +
            '									{{else}}' +
            '										<i class="fa fa-check"></i>' +
            '									{{/if}}' +
            '								{{/if}}' +
            '							{{/each}}' +
            '						{{else}}' +
            '							<i class="fa fa-check"></i>' +
            '						{{/if}}' +
            '					{{/if}}' +
            '				</td>' +
            '			{{/each}}' +
            '		</tr>' +
            '	{{/each}}' +
            '</script>';
    }
    var tickText = function () {
        return '<script id="tpl_specialtyBag_tickText" type="text/html">' +
            '	{{each val as val k1}}' +
            '		<td>' +
            '			{{if val=="true"}}' +
            '				<i class="fa fa-check"></i>' +
            '			{{else if val=="false"}}' +
            '			{{else}}' +
            '				{{val}}' +
            '			{{/if}}' +
            '		</td>' +
            '	{{/each}}' +
            '</script>';
    }
    var tick = function () {
        return '<script id="tpl_specialtyBag_tick" type="text/html">' +
            '	{{each val as val k1}}' +
            '		<td>' +
            '			{{if val=="true"}}' +
            '				<i class="fa fa-check"></i>' +
            '			{{/if}}' +
            '		</td>' +
            '	{{/each}}' +
            '</script>';
    }
    var text = function () {
        return '<script id="tpl_specialtyBag_text" type="text/html">' +
            '	{{each value as val i}}' +
            '		<td><p class="form-control-static">{{val}}</p></td>' +
            '	{{/each}}' +
            '</script>';
    }

    var texts = function () {
        return '<script id="tpl_specialtyBag_texts" type="text/html">' +
            '	{{each value as val i}}' +
            '		<td><img src="{{val}}" style="width: 150px" alt=""></td>' +
            '	{{/each}}' +
            '</script>';
    }

    return tpl;
});
